package com.have.blog.web.service.impl;

import com.have.blog.base.enums.BlogStatus;
import com.have.blog.model.mapper.BlogCategoryMapper;
import com.have.blog.model.models.BlogCategory;
import com.have.blog.model.models.BlogCategoryExample;
import com.have.blog.utils.MyBeanUtils;
import com.have.blog.web.dto.BlogCategoryDto;
import com.have.blog.web.service.BlogCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@SuppressWarnings("all")
public class BlogCategoryServiceImpl implements BlogCategoryService {
    @Autowired
    private BlogCategoryMapper categoryMapper;

    @Override
    public List<BlogCategoryDto> getList() {
        BlogCategoryExample example = new BlogCategoryExample();
        example.createCriteria()
                .andStatusEqualTo(BlogStatus.ENABLE.getStatus());
        example.setOrderByClause("sort desc");
        List<BlogCategory> blogSortList = categoryMapper.selectByExample(example);
        List<BlogCategoryDto> resultList = MyBeanUtils.copyListProperties(blogSortList, BlogCategoryDto::new);
        return resultList;
    }
}
